(function (lib, config) {
    var loadFunc = function () {
        var textAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|'), textcolorAry = config.textcolor.split('|'), imglinkAry = config.imglink.split('|'), weblinkAry = config.weblink.split('|'), identiAry = config.identifier.split('|');
        textAry[0] = textAry[0] || '今日值班医师';
        textAry[1] = textAry[1] || '你好，我是今天的值班医生。想了解哪方面的问题？我可以为你详细讲解，并提供科学的建议指导。';
        textAry[2] = textAry[2] || '治疗分析';
        textAry[3] = textAry[3] || '了解费用';
        textAry[4] = textAry[4] || '用药指导';
        textAry[5] = textAry[5] || '出现症状后你到医院看过了吗？点击下面的通道按钮，我会针对性为你详细分析解答，并给予科学的建议指导。';
        textAry[6] = textAry[6] || '已就诊过';
        textAry[7] = textAry[7] || '还未就诊';
        textAry[8] = textAry[8] || '预约挂号';
        textAry[9] = textAry[9] || '想了解哪方面的问题？不如直接和我聊聊，相信比你自己盲目看效果要好。';
        textAry[10] = textAry[10] || '快速问诊';
        textAry[11] = textAry[11] || '治疗方案';
        textAry[12] = textAry[12] || '优惠套餐';
        textcolorAry[0] = textcolorAry[0] || '#ffffff';
        textcolorAry[1] = textcolorAry[1] || '#000';
        textcolorAry[2] = textcolorAry[2] || '#000000';
        textcolorAry[3] = textcolorAry[3] || '#fff';
        textcolorAry[4] = textcolorAry[4] || '#fff';
        textcolorAry[5] = textcolorAry[5] || '#000';
        textcolorAry[6] = textcolorAry[6] || '#fff';
        textcolorAry[7] = textcolorAry[7] || '#fff';
        textcolorAry[8] = textcolorAry[8] || '#fff';
        textcolorAry[9] = textcolorAry[9] || '#000';
        textcolorAry[10] = textcolorAry[10] || '#fff';
        textcolorAry[11] = textcolorAry[11] || '#fff';
        textcolorAry[12] = textcolorAry[12] || '#fff';
        bgcolorAry[0] = bgcolorAry[0] || '#f8f8f8';
        bgcolorAry[1] = bgcolorAry[1] || '#e7453a';
        bgcolorAry[2] = bgcolorAry[2] || '#FFFFFF';
        bgcolorAry[3] = bgcolorAry[3] || '#e7453a';
        imglinkAry[0] = imglinkAry[0] || 'http://wap.hdyy.com.cn/swt/js20171013/img/swth5_tx.jpg';
        imglinkAry[1] = imglinkAry[1] || 'http://wap.hdyy.com.cn/swt/js20171013/img/swtdh_top.png';
        imglinkAry[2] = imglinkAry[2] || 'http://wap.hdyy.com.cn/swt/js20171013/img/swth5_jt.jpg';
        imglinkAry[3] = imglinkAry[3] || 'http://wap.hdyy.com.cn/swt/js20171013/img/swth5_sz.png';
        weblinkAry[0] = weblinkAry[0] || 'tel:029-62513333';
        identiAry[0] = identiAry[0] || 'bottom_tan';

        var htmlStr = [];
        htmlStr.push("<style type=\'text/css\'>");/*left:0;right:0;bottom:0*/
        htmlStr.push("#LRdiv0,#LRdiv1,#LRdiv2,#LRdiv3{display:none!important;}#swt_dbdh{line-height: 1.6em;max-width:640px;min-width:320px;margin:auto;overflow:hidden;clear:both;font-size:1.1em;position:fixed;"+lib.util.getPosStyle(config)+";z-index:100;display:none;font-family:Microsoft YaHei;z-index:9999999999999;}#swt_dbdh dd{margin:0;}#swt_dbdh img{max-width:100%;vertical-align:top;border:0;outline:0}#swt_dbdh li{list-style:none;}#swt_dbdh a{text-decoration:none;color:" + '#fff' + ";display:block;}.swtdh_nr:after,.clearfix:after{visibility:hidden;display:block;font-size:0;content:\'\';clear:both;height:0;}.swtdh_nr,.clearfix{zoom:1;}.swtdh_nr{height:16.4em;width:100%;margin:auto;overflow:hidden;background:" + bgcolorAry[0] + ";}.swtdh_nr ul{background:" + bgcolorAry[1] + ";display: -webkit-box;-webkit-box-pack:justify;-webkit-box-align:center;height:2.85em;width:100%;padding:0 3.125%;box-sizing:border-box;color:" + '#fff' + ";margin:0;}.swtdh_nr ul li:nth-child(1){cursor:pointer;}.swtdh_nr ul li:nth-child(2){font-size:1.4em;}.swtdh_nr ul li:nth-child(3){width:7.5%;cursor:pointer;}.swtdh_nr ul li:nth-child(3) img{display:block;}.swtdh_nr div{width:93.75%;margin:.75em auto .5em auto;overflow:auto;}.db_dl1{margin:0 0 1em 0;opacity:0;transition:1s;-webkit-transition:1s;width:90%;display: -webkit-box;-webkit-box-pack:justify;}.db_dl1 dt{width:18.5%;}.db_dl1 dd{color: " + textcolorAry[1] + ";-webkit-box-align: center;display: -webkit-box;width:77%;border-radius:.3em;border:1px #e1e1e1 solid;padding:1% 1% 1.5% 3%;box-sizing:border-box;position:relative;background:" + bgcolorAry[2] + ";}.db_dl1 dd:after{content:\'\';position:absolute;width:.54em;height:.625em;background:url(" + imglinkAry[2] + ") no-repeat center;background-size:100% 100%;left:-.54em;top:1em}.swtdh_nr ol{width:90%;text-align:center;display: -webkit-box;-webkit-box-pack:justify;-webkit-box-align:center;margin:0 auto;padding:0;margin-bottom:1em;position:absolute;left:0;right:0;bottom:0;height:5em;}.swtdh_nr ol p{position:absolute;width:1.75em;height:2.33em;left:0;right:0;top:0;background:url(" + imglinkAry[3] + ") no-repeat center;background-size:100% 100%;margin:auto;animation:dhw 1s infinite;-webkit-animation:dhw 1s infinite;display:none;}.swtdh_nr ol li{box-sizing:border-box;padding:0 1%;width:30%;background:" + bgcolorAry[3] + ";border-radius:.8em;color:" + textcolorAry[2] + ";line-height:3.3em;cursor:pointer;animation:an_show 1.3s ease-out infinite 1s;-webkit-animation:an_show 1.3s ease-out infinite 1s;margin:2em 0 -8.5em 0;transition:.8s cubic-bezier(0,0,.29,1.09);-webkit-transition:.8s cubic-bezier(0,0,.29,1.09);}@keyframes an_show{0%{-webkit-transform:scale(1);}30.7%{-webkit-transform:scale(.92);}61.4%{-webkit-transform:scale(1);}100%{-webkit-transform:scale(1);}}@-webkit-keyframes an_show{0%{-webkit-transform:scale(1);}30.7%{-webkit-transform:scale(.92);}61.4%{-webkit-transform:scale(1);}100%{-webkit-transform:scale(1);}}@keyframes dhw{20%{top:-.1em;opacity:0.8;}40%{top:-.2em;opacity:0.5;}60%{top:-.3em;opacity:0.3;}80%{top:-.2em;opacity:0.6;}100%{top:0em;opacity:1;}}@-webkit-keyframes dhw{20%{top:-.1em;opacity:0.8;}40%{top:-.2em;opacity:0.5;}60%{top:-.3em;opacity:0.3;}80%{top:-.2em;opacity:0.6;}100%{top:0em;opacity:1;}}@media only screen and (min-width:640px){#swt_dbdh{font-size:24px;}}@media only screen and (min-width:540px)and (max-width:639px){#swt_dbdh{font-size:17px;}}@media only screen and (min-width:414px)and (max-width:539px){#swt_dbdh{font-size:15px;}}@media only screen and (min-width:375px)and (max-width:413px){#swt_dbdh{font-size:15px;}}@media only screen and (min-width:342px)and (max-width:374px){#swt_dbdh{font-size:13px;}}@media only screen and (min-width:320px)and (max-width:341px){#swt_dbdh{font-size:13px;}}</style>");
        htmlStr.push("<article id=\'swt_dbdh\'><article class=\'swtdh_nr\'><ul><li onclick=\'swtdh_gb();\'><关闭</li><li style='color:"+textcolorAry[0]+";'>" + textAry[0] + "</li><li><a href=\"" + weblinkAry[0] + "\"><img src=\'" + imglinkAry[1] + "\'/></a></li></ul><div id=\'swtdh_dh\'><dl class=\'db_dl1\'><dt><img src=\'" + imglinkAry[0] + "\'/></dt><dd>" + textAry[1] + "</dd></dl></div><ol><li>" + textAry[2] + "</li><li>" + textAry[3] + "</li><li>" + textAry[4] + "</li><p></p></ol></article></article>");
        var o = document.createElement('div');
        o.innerHTML = htmlStr.join('');
        while (o.firstElementChild) {
            document.body.appendChild(o.firstElementChild);
        };
        swtdh = document.getElementById('swt_dbdh');
        swt_dl = document.querySelector('.swtdh_nr div dl');
        swt_an = document.querySelectorAll('.swtdh_nr ol li');
        swt_an_p = document.querySelector('.swtdh_nr ol p');
        //弹出对话框
        swtdh_show = function () { swtdh.style.display = 'block'; setTimeout(function () { swt_dl.style.opacity = 1; setTimeout(swt_show, 800) }, 700) }
        swtdh_show2 = function () { swtdh.style.display = 'block'; setTimeout(function () { swt_dl.style.opacity = 1; }, 300) }
        //弹出医生对话
        swt_show = function () { for (var i = 0; i < swt_an.length; i++) { swt_an[i].style.marginBottom = 0 + 'em'; } swt_an_p.style.display = 'block'; document.querySelector('.db_dl1 dd').innerHTML = textAry[1]; setTimeout(swt_show_1, 0); setTimeout(swt_show2, 8000) }
        swt_show_1 = function () {
            //document.querySelector('.swtdh_nr ol li:nth-child(1)').innerHTML = textAry[2];
            //document.querySelector('.swtdh_nr ol li:nth-child(2)').innerHTML = textAry[3];
            //document.querySelector('.swtdh_nr ol li:nth-child(3)').innerHTML = textAry[4];
            setStyleVal('.swtdh_nr ol li:nth-child(1)', textAry[2], textcolorAry[2]);
            setStyleVal('.swtdh_nr ol li:nth-child(2)', textAry[3], textcolorAry[3]);
            setStyleVal('.swtdh_nr ol li:nth-child(3)', textAry[4], textcolorAry[4]);
        }
        //弹出医生对话2
        swt_show2 = function () { setStyleVal('.db_dl1 dd', textAry[5], textcolorAry[5]); setTimeout(swt_show2_1, 0); setTimeout(swt_show3, 8000) }
        swt_show2_1 = function () {
            //document.querySelector('.swtdh_nr ol li:nth-child(1)').innerHTML = textAry[6];
            //document.querySelector('.swtdh_nr ol li:nth-child(2)').innerHTML = textAry[7];
            //document.querySelector('.swtdh_nr ol li:nth-child(3)').innerHTML = textAry[8];
            setStyleVal('.swtdh_nr ol li:nth-child(1)', textAry[6], textcolorAry[6]);
            setStyleVal('.swtdh_nr ol li:nth-child(2)', textAry[7], textcolorAry[7]);
            setStyleVal('.swtdh_nr ol li:nth-child(3)', textAry[8], textcolorAry[8]);
        }
        //弹出医生对话3
        swt_show3 = function () { setStyleVal('.db_dl1 dd', textAry[9], textcolorAry[9]); setTimeout(swt_show3_1, 0); setTimeout(swt_show, 8000) }
        swt_show3_1 = function () {
            //document.querySelector('.swtdh_nr ol li:nth-child(1)').innerHTML = textAry[10];
           // document.querySelector('.swtdh_nr ol li:nth-child(2)').innerHTML = textAry[11];
            // document.querySelector('.swtdh_nr ol li:nth-child(3)').innerHTML = textAry[12];
            setStyleVal('.swtdh_nr ol li:nth-child(1)', textAry[10], textcolorAry[10]);
            setStyleVal('.swtdh_nr ol li:nth-child(2)', textAry[11], textcolorAry[11]);
            setStyleVal('.swtdh_nr ol li:nth-child(3)', textAry[12], textcolorAry[12]);
        }
        function setStyleVal(selector,innerHTML,color) {
            var ele = document.querySelector(selector);
            ele.innerHTML = innerHTML;
            ele.style.color = color;
        }
        setTimeout(swtdh_show, config.firsttime * 1000);

        //点击打开商务通
        for (var i = 0; i < swt_an.length; i++) { swt_an[i].index = i; swt_an[i].onclick = function () { openZoosUrl('chatwin', '&e=' + identiAry[0] + '') } }
        //关闭对话框
        swtdh_gb = function () { swt_dl.style.opacity = 0; swtdh.style.display = 'none'; setTimeout(swtdh_show2, config.relapsetime * 1000); }

    };
    lib.load(loadFunc);
})('{{lib}}', '{{config}}');
